package services

import (
	"html/template"
	"net/http"
	"vegetable/common"
)

// 运单信息上链
func UpChainWaybill(w http.ResponseWriter, r *http.Request) {

	waybillID := r.FormValue("waybillID")
	waybillContent := r.FormValue("waybillContent")

	waybillHash := common.SM3(waybillID + waybillContent)

	t, err := template.ParseFiles("website/upchain.html")
	if err != nil {
		http.Redirect(w, r, "/", http.StatusFound)
	}
	t.Execute(w, waybillHash)
}

// 验证运单信息

// 运单信息查询
func QueryWaybill(w http.ResponseWriter, r *http.Request) {

	waybillHash := r.FormValue("waybillHash")

	waybillHashResult := common.SM3(waybillHash)

	t, err := template.ParseFiles("website/query.html")
	if err != nil {
		http.Redirect(w, r, "/", http.StatusFound)
	}
	t.Execute(w, waybillHashResult)
}
